package com.agy.filemanager.service.impl;

import com.agy.filemanager.entity.DcBaseUserRole;
import com.agy.filemanager.entity.TreeModel;
import com.agy.filemanager.mapper.DcSystemBaseUserRoleDao;
import com.agy.filemanager.service.DcSystemBaseUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 登陆模块-
 * @author cj
 */
@Service
public class DcSystemBaseUserRoleServiceImpl implements DcSystemBaseUserRoleService {
    @Autowired
    private DcSystemBaseUserRoleDao dcBaseUserRoleDao;

    /**
     * 获取安工院人员组织机构树
     * @return
     */
    @Override
    public List<TreeModel> getAgyuserTree() {
        List<TreeModel> treeModels = dcBaseUserRoleDao.getAgyuserTree();
        return treeModels;
    }

    /**
     * 新增-保存人员角色关系
     * @param entity
     * @return
     */
    @Transactional
    @Override
    public int saveUserRole(DcBaseUserRole entity) {
        return dcBaseUserRoleDao.insertEntity(entity);
    }

    /**
     * 根据userId获取人员角色关系
     * @param userId
     * @return
     */
    @Override
    public List<DcBaseUserRole> getUserRole(String userId) {
        return dcBaseUserRoleDao.selectByUserId(userId);
    }

    /**
     * 根据userId删除人员-角色关系
     * @param userId
     * @return
     */
    @Override
    public int deleteByUserId(String userId) {
        return dcBaseUserRoleDao.deleteByUserId(userId);
    }
}
